Plot KAZR data with Proper
Plot KAZR data with Proper#
import pyart
import xarray as xr
from distributed import LocalCluster, Client
import glob
import hvplot.xarray
import holoviews as hv
from bokeh.models import HoverTool
cluster = LocalCluster()
client = Client(cluster)
client
2022-03-22 22:53:33,532 - distributed.diskutils - INFO - Found stale lock file and directory '/Users/mgrover/git_repos/tracer-radar-analysis/notebooks/march-22-2022/dask-worker-space/worker-uqj_sb1s', purging
2022-03-22 22:53:33,533 - distributed.diskutils - INFO - Found stale lock file and directory '/Users/mgrover/git_repos/tracer-radar-analysis/notebooks/march-22-2022/dask-worker-space/worker-m2wxo13m', purging
2022-03-22 22:53:33,533 - distributed.diskutils - INFO - Found stale lock file and directory '/Users/mgrover/git_repos/tracer-radar-analysis/notebooks/march-22-2022/dask-worker-space/worker-7la94o81', purging
2022-03-22 22:53:33,534 - distributed.diskutils - INFO - Found stale lock file and directory '/Users/mgrover/git_repos/tracer-radar-analysis/notebooks/march-22-2022/dask-worker-space/worker-b4qv_1fd', purging
Client
Client-cf9a1946-aa5c-11ec-8d1e-acde48001122
| Connection method: Cluster object | Cluster type: distributed.LocalCluster |
| Dashboard: http://127.0.0.1:8787/status |
Cluster Info
LocalCluster
c6c7bd28
| Dashboard: http://127.0.0.1:8787/status | Workers: 4 |
| Total threads: 12 | Total memory: 16.00 GiB |
| Status: running | Using processes: True |
Scheduler Info
Scheduler
Scheduler-018a8f93-4b5f-4bbb-b348-77bb6871a44f
| Comm: tcp://127.0.0.1:50176 | Workers: 4 |
| Dashboard: http://127.0.0.1:8787/status | Total threads: 12 |
| Started: Just now | Total memory: 16.00 GiB |
Workers
Worker: 0
| Comm: tcp://127.0.0.1:50196 | Total threads: 3 |
| Dashboard: http://127.0.0.1:50197/status | Memory: 4.00 GiB |
| Nanny: tcp://127.0.0.1:50181 | |
| Local directory: /Users/mgrover/git_repos/tracer-radar-analysis/notebooks/march-22-2022/dask-worker-space/worker-5bc3pvt6 | |
Worker: 1
| Comm: tcp://127.0.0.1:50187 | Total threads: 3 |
| Dashboard: http://127.0.0.1:50189/status | Memory: 4.00 GiB |
| Nanny: tcp://127.0.0.1:50179 | |
| Local directory: /Users/mgrover/git_repos/tracer-radar-analysis/notebooks/march-22-2022/dask-worker-space/worker-x4zu8uqx | |
Worker: 2
| Comm: tcp://127.0.0.1:50188 | Total threads: 3 |
| Dashboard: http://127.0.0.1:50192/status | Memory: 4.00 GiB |
| Nanny: tcp://127.0.0.1:50180 | |
| Local directory: /Users/mgrover/git_repos/tracer-radar-analysis/notebooks/march-22-2022/dask-worker-space/worker-ris_bd02 | |
Worker: 3
| Comm: tcp://127.0.0.1:50191 | Total threads: 3 |
| Dashboard: http://127.0.0.1:50194/status | Memory: 4.00 GiB |
| Nanny: tcp://127.0.0.1:50182 | |
| Local directory: /Users/mgrover/git_repos/tracer-radar-analysis/notebooks/march-22-2022/dask-worker-space/worker-oqdifb4a | |
files = sorted(glob.glob('../../data/kazr/houkazrcfrgeM1.a1.20220315*'))
def plot_kazr(ds, max_height):
ds['time'] = ds.time.astype(int)/10**6
ref = ds.reflectivity.compute()
vel = ds.mean_doppler_velocity.compute()
max_height = 9000
ref_plot = ref.compute().hvplot.quadmesh(x='time',
y='range',
rasterize=True,
cmap='pyart_HomeyerRainbow',
ylim=(0, max_height),
height=300,
width=700,
clim=(-20, 40),
label='Reflectivity (dBZ)',
xlabel='Date (UTC)',
hover=True).opts(hooks=[apply_formatter])
vel_plot = vel.compute().hvplot.quadmesh(x='time',
y='range',
rasterize=True,
cmap='pyart_balance',
ylim=(0, max_height),
height=300,
width=700,
clim=(-8, 8),
label='Velocity (m/s)',
xlabel='Date (UTC)',
hover=True).opts(hooks=[apply_formatter])
return (ref_plot + vel_plot).cols(1)
ds = xr.open_mfdataset(files,
use_cftime=True,
chunks={'time':2000})
ds['time'] = ds.indexes['time'].to_datetimeindex()
/Users/mgrover/opt/anaconda3/envs/tracer-dev/lib/python3.9/site-packages/xarray/coding/times.py:351: FutureWarning: Index.ravel returning ndarray is deprecated; in a future version this will return a view on self.
sample = dates.ravel()[0]
ds['time'] = ds.time.astype(int)/10**6
from bokeh.models import DatetimeTickFormatter
def apply_formatter(plot, element):
plot.handles['xaxis'].formatter = DatetimeTickFormatter(hours='%m/%d/%Y \n %H:%M',
minutes='%m/%d/%Y \n %H:%M',
hourmin='%m/%d/%Y \n %H:%M')
ref = ds.reflectivity.compute()
vel = ds.mean_doppler_velocity.compute()
max_height = 9000
ref_plot = ref.compute().hvplot.quadmesh(x='time',
y='range',
rasterize=True,
cmap='pyart_HomeyerRainbow',
ylim=(0, max_height),
height=300,
width=700,
clim=(-20, 40),
label='Reflectivity (dBZ)',
xlabel='Date (UTC)',
hover=True).opts(hooks=[apply_formatter])
vel_plot = vel.compute().hvplot.quadmesh(x='time',
y='range',
rasterize=True,
cmap='pyart_balance',
ylim=(0, max_height),
height=300,
width=700,
clim=(-8, 8),
label='Velocity (m/s)',
xlabel='Date (UTC)',
hover=True).opts(hooks=[apply_formatter])
(ref_plot + vel_plot).cols(1)
lon, lat = ds.lon.values[0], ds.lat.values[0]
print(lat, lon)
29.670000076293945 -95.05899810791016